package com.example.administrator.testpersionn.utlis;


import android.content.Context;
import android.content.Intent;
import android.os.Parcelable;


import java.util.HashMap;
import java.util.Map;


public class ActivityUtils {
    //跳转的activit的class值
    public static Class aactivity;
    //跳转的activit需要的参数，全部用String类型,需要什么直接转，
    public static Map<String,String> parems=new HashMap<>();
    //跳转的主页面需要选中的模块
    public static int selecIndex=0;

    /**
     * 控制跳转页面是否需要登录
     * @param context
     * @param activity
     * @param isLogin
     */
    public void startActivity(Context context, Class activity, boolean isLogin){
        if(isLogin&&loginActivity!=null){
            intent.setClass(context,loginActivity);
            intent.putExtra("isTrue",isLogin);
            com.example.administrator.out1.utlis.ActivityUtils.aactivity=activity;
            context.startActivity(intent);
        }else{
            intent.setClass(context,activity);
            context.startActivity(intent);
        }
    }
    boolean isLogin=false;

    Intent intent=new Intent();
    
    Context context;

    private Class loginActivity;

    public ActivityUtils(Context context) {
        this.context = context;
    }

    public static com.example.administrator.out1.utlis.ActivityUtils initActivity(Context context){
        parems=new HashMap<>();
       return new com.example.administrator.out1.utlis.ActivityUtils(context);
    }

    public com.example.administrator.out1.utlis.ActivityUtils isLogin(boolean isLogin){
        this.isLogin=isLogin;
        return this;
    }

    public void startActivity(Class activity){
        startActivity(context,activity,isLogin);
    }

    public com.example.administrator.out1.utlis.ActivityUtils setLoginActivity(Class loginActivity) {
        this.loginActivity = loginActivity;
        return this;
    }
    
    public com.example.administrator.out1.utlis.ActivityUtils putExtra(String name, boolean value) {
        intent.putExtra(name,value);
        return this;
    }


    public com.example.administrator.out1.utlis.ActivityUtils putExtra(String name, byte value) {
        intent.putExtra(name,value);
        return this;
    }


    public com.example.administrator.out1.utlis.ActivityUtils putExtra(String name, char value) {
        intent.putExtra(name,value);
        return this;
    }


    public com.example.administrator.out1.utlis.ActivityUtils putExtra(String name, short value) {
        intent.putExtra(name,value);
        return this;
    }


    public com.example.administrator.out1.utlis.ActivityUtils putExtra(String name, int value) {
        intent.putExtra(name,value);
        return this;
    }


    public com.example.administrator.out1.utlis.ActivityUtils putExtra(String name, long value) {
        return this;
    }


    public com.example.administrator.out1.utlis.ActivityUtils putExtra(String name, float value) {
        intent.putExtra(name,value);
        return this;
    }


    public com.example.administrator.out1.utlis.ActivityUtils putExtra(String name, double value) {
        return this;
    }


    public com.example.administrator.out1.utlis.ActivityUtils putExtra(String name, String value) {
        intent.putExtra(name,value);
        return this;
    }


    public com.example.administrator.out1.utlis.ActivityUtils putExtra(String name, CharSequence value) {
        intent.putExtra(name,value);
        return this;
    }


    public com.example.administrator.out1.utlis.ActivityUtils putExtra(String name, Parcelable value) {
        intent.putExtra(name,value);
        return this;
    }


    public com.example.administrator.out1.utlis.ActivityUtils putExtra(String name, Parcelable[] value) {
        intent.putExtra(name,value);
        return this;
    }
}
